package com.tiancheng.trade.settlement.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

/**
 * @Auther: Likailun
 * @Date: 11:10 2021/4/23
 * @Description: 收入确认规则枚举
 */
@Getter
@AllArgsConstructor
public enum RevenueTypeEnum {
    ALL("ALL", "全额确认","销售金额=收入",false),
    PART("PART", "差额确认","销售金额-成本金额=收入",false),
    FIXED_SCALE("FIXED_SCALE", "固定比例","销售金额*固定比例=收入",true),
    FIXED_AMOUNT("FIXED_AMOUNT", "固定金额","销售数量*固定金额=收入",true),
    SUMMATION("SUMMATION", "合计","以上所有合计",false);

    /**
     * 收入确认类型
     */
    private String revenueType;

    /**
     * 收入确认类型-名称
     */
    private String revenueTypeName;

    /**
     * 收入确认类型-描述
     */
    private String revenueTypeDesc;

    /**
     * 收入确认类型-是否自定义
     */
    private Boolean custom;

    public static List<RevenueTypeEnum> getAll() {
        return Arrays.asList(RevenueTypeEnum.values());
    }

    public static String getDesc(String revenueType) {
        RevenueTypeEnum[] revenueTypeEnums = values();
        for (RevenueTypeEnum statusEnum : revenueTypeEnums) {
            if (statusEnum.getRevenueType().equals(revenueType)) {
                return statusEnum.getRevenueTypeName();
            }
        }
        return null;
    }

    public static RevenueTypeEnum getRevenueTypeEnum(String revenueType) {
        RevenueTypeEnum[] revenueTypeEnums = values();
        for (RevenueTypeEnum statusEnum : revenueTypeEnums) {
            if (statusEnum.getRevenueType().equalsIgnoreCase(revenueType)) {
                return statusEnum;
            }
        }
        return null;
    }

}
